//
//  TopTableViewCell.m
//  WhereToTravel
//
//  Created by dlios on 15/10/12.
//  Copyright © 2015年 zhoushengmin. All rights reserved.
//

#import "TopTableViewCell.h"

#define W self.contentView.frame.size.width/375
#define H self.contentView.frame.size.height/90

@implementation TopTableViewCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self createView];
        [[NSNotificationCenter defaultCenter] postNotificationName:@"night" object:nil];
        [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(night) name:@"night" object:nil];
    }
    return self;
}

- (void)createView {
    [super createView];
    self.leftImageView = [[UIImageView alloc] init];
    [self.contentView addSubview:self.leftImageView];
    
    self.downLeftImageView = [[UIImageView alloc] init];
    [self.contentView addSubview:self.downLeftImageView];
    
    self.downRightImageView = [[UIImageView alloc] init];
    [self.contentView addSubview:self.downRightImageView];

    self.upLabel.font = [UIFont fontWithName:@"Helvetica-Bold" size:14];
    
    self.mistLabel.font = [UIFont systemFontOfSize:10];
    
    self.downLeftLabel.font = [UIFont systemFontOfSize:12];
    
    self.downRightLabel.font = [UIFont systemFontOfSize:12];
}

- (void)layoutSubviews {
    [super layoutSubviews];
    self.leftImageView.frame = CGRectMake(5 * W, 10 * H, 100 * W, 70 * H);
    self.upLabel.frame = CGRectMake(110 * W, 0 * H, 260 * W, 40 * H);
    self.mistLabel.frame = CGRectMake(110 * W, 35 * H, 130 * W, 30 * H);
    self.downLeftImageView.frame = CGRectMake(110 * W, 65 *H, 20 * W, 15 * H);
    self.downLeftLabel.frame = CGRectMake(140 * W, 65 * H, 80 * W, 15 * H);
    self.downRightImageView.frame = CGRectMake(240 * W, 65 * H, 20 * W, 15 * H);
    self.downRightLabel.frame = CGRectMake(265 * W, 65 * H, 40 * W, 15 * H);
}

- (void)night {
    if ([SingletonNight shareSingletonNight].isSelete == YES) {
        self.upLabel.textColor = [UIColor whiteColor];
        self.mistLabel.textColor = [UIColor whiteColor];
        self.downLeftLabel.textColor = [UIColor whiteColor];
        self.downRightLabel.textColor = [UIColor whiteColor];
    }
    else {
        self.upLabel.textColor = [UIColor blackColor];
        self.mistLabel.textColor = [UIColor blackColor];
        self.downLeftLabel.textColor = [UIColor blackColor];
        self.downRightLabel.textColor = [UIColor blackColor];

    }
}

- (void)dealloc
{
    [[NSNotificationCenter defaultCenter] removeObserver:self name:@"night" object:nil];
}



@end
